package java19_11_18;

import java.util.Scanner;

//汉诺塔问题
public class Num7 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        //定义三个轮盘名称
        char A = 'A';
        char B = 'B';
        char C = 'C';
        hanoi(n, A, B, C);
    }

    //参数列表中的a，b，c。a为起始轮盘，b为辅助轮盘，c为目的轮盘。与轮盘名称不同
    private static void hanoi(int n, char a, char b, char c) {
        if (n == 1) {
            //当只剩一个轮盘时，将它从A放到C轮盘上就行
            System.out.println(a + "->" + c);
        } else {
            //否则。先将n-1个放到B轮盘
            hanoi(n - 1, a, c, b);
            //然后将最后一个轮盘，从A放到C
            System.out.println(a + "->" + c);
            //最后将之前的n-1再从B放到C上
            hanoi(n - 1, b, a, c);
        }
    }
}
